<?php

namespace Plugins\Demo\Http\Admin\Controller;

use App\Util\Response;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\PostMapping;
use Hyperf\View\Render;
use Psr\Http\Message\ResponseInterface;

#[Controller('admin/plugins/demo')]
class IndexController
{
    /**
     * @param Render $render
     * @return ResponseInterface
     */
    #[GetMapping('')]
    public function index(Render $render): ResponseInterface
    {
        return $render->render('plugins.Demo.Admin.Index.index');
    }

    /**
     * @param Render $render
     * @return ResponseInterface
     */
    #[GetMapping('demoForm')]
    public function demoForm(Render $render): ResponseInterface
    {
        return $render->render('plugins.Demo.Admin.Index.demo_form');
    }

    /**
     * @return ResponseInterface
     */
    #[PostMapping('demoDel')]
    public function demoDel(): ResponseInterface
    {
        return Response::json()->success();
    }

    /**
     * @return ResponseInterface
     */
    #[GetMapping('listData')]
    public function demoListData(): ResponseInterface
    {
        return Response::json()->success([
            'data' => [
                ['id' => 1, 'name' => 'demo1', 'status' => 1, 'created_at' => '2022-01-01 00:00:00', 'age' => 18, 'sex' => 1, 'sex_text' => '男', 'intro' => '男人至死是少年，女人至死是少女'],
                ['id' => 2, 'name' => 'demo2', 'status' => 1, 'created_at' => '2022-01-01 00:00:00', 'age' => 18, 'sex' => 1, 'sex_text' => '男', 'intro' => '男人至死是少年，女人至死是少女'],
                ['id' => 3, 'name' => 'demo3', 'status' => 1, 'created_at' => '2022-01-01 00:00:00', 'age' => 18, 'sex' => 1, 'sex_text' => '男', 'intro' => '男人至死是少年，女人至死是少女'],
                ['id' => 4, 'name' => 'demo4', 'status' => 1, 'created_at' => '2022-01-01 00:00:00', 'age' => 18, 'sex' => 1, 'sex_text' => '男', 'intro' => '男人至死是少年，女人至死是少女'],
                ['id' => 5, 'name' => 'demo5', 'status' => 1, 'created_at' => '2022-01-01 00:00:00', 'age' => 18, 'sex' => 1, 'sex_text' => '男', 'intro' => '男人至死是少年，女人至死是少女'],
                ['id' => 6, 'name' => 'demo6', 'status' => 1, 'created_at' => '2022-01-01 00:00:00', 'age' => 18, 'sex' => 1, 'sex_text' => '男', 'intro' => '男人至死是少年，女人至死是少女'],
                ['id' => 7, 'name' => 'demo7', 'status' => 1, 'created_at' => '2022-01-01 00:00:00', 'age' => 18, 'sex' => 1, 'sex_text' => '男', 'intro' => '男人至死是少年，女人至死是少女'],
                ['id' => 8, 'name' => 'demo8', 'status' => 1, 'created_at' => '2022-01-01 00:00:00', 'age' => 18, 'sex' => 1, 'sex_text' => '男', 'intro' => '男人至死是少年，女人至死是少女'],
                ['id' => 9, 'name' => 'demo9', 'status' => 1, 'created_at' => '2022-01-01 00:00:00', 'age' => 18, 'sex' => 1, 'sex_text' => '男', 'intro' => '男人至死是少年，女人至死是少女'],
                ['id' => 10, 'name' => 'demo10', 'status' => 1, 'created_at' => '2022-01-01 00:00:00', 'age' => 18, 'sex' => 1, 'sex_text' => '男', 'intro' => '男人至死是少年，女人至死是少女'],
            ],
            'total' => 20
        ]);
    }
}